<template>
	<view>
		<image style="width: 100%;" 
			mode="widthFix" src="../static/imgs/ystop.png">
		</image>
		<view style="width: 100%;position: relative;background-color: #FFFFFF;padding-bottom: 10rpx;">
			<image :src="docListInfo.photo" style="position: absolute;top:-60rpx;left: 40rpx;width: 120rpx;height: 120rpx;border-radius: 50%;"></image>
			<button class="fx-btn" style="position: absolute;top:-100rpx;right: 40rpx;display: flex;flex-direction: column;align-items: center;background-color: rgba(255,255,255,0.0);border-width: 0rpx;"  open-type="share">
				<image src="../static/imgs/fx.png" style="width: 36rpx;" mode="widthFix"></image>
				<text style="color: #FFFFFF;font-size: 25rpx;">分享名片</text>
			</button>
			<view style="width: 100%;display: flex;align-items: center;justify-content: flex-end;height: 80rpx;">
				<view style="background: #FDF8F8;border-radius: 25rpx;height: 50rpx;width: 175rpx;display: flex;align-items: center;justify-content: center;margin-right: 20rpx;">
					<image style="height: 50%;margin-right: 10rpx;"
						mode="heightFix" :src="docListInfo.isUsrCollectDoc==1?'../static/imgs/gzxz@2x.png':'../static/imgs/gz@2x.png'">
					</image>
					<view v-if="docListInfo.isUsrCollectDoc==1" style="color: #BE965B;" @click="deleteDcoId(docListInfo.id)">已关注</view>
					<view style="color: #BE965B;" @click="insertDcoId(docListInfo.id)" v-else>关注医生</view>
				</view>
				<view style="color: #4C4242;display: flex;align-items: center;" @click="getDocInfoPage()">
					<text style="margin-right: 10rpx;">医生信息</text>
					<image style="height: 32rpx;margin-right: 40rpx;" mode="heightFix" src="../static/imgs/fh.png">
					</image>
				</view>
			</view>
			<view style="display: flex;align-items: center;margin-top: 0rpx;">
				<view style="font-weight: bold;margin-left: 40rpx;font-size: 40rpx;">{{docListInfo.name}}</view>
				<view style="margin-left: 20rpx;">{{docListInfo.deptName}}</view>
				<view style="margin-left: 20rpx;">{{docListInfo.title}}</view>
			</view>
			<view style="display: flex;align-items: center;margin-top: 20rpx;justify-content: space-between;padding-left: 40rpx;padding-right: 40rpx;box-sizing: border-box;">
				<view>已服务：<text style="color: #FF8A00;">{{recNum>=1000?'>1000':'<1000'}}人</text></view>
				<view>接诊率：<text style="color: #FF8A00;">100%</text></view>
				<view>平均回复：<text style="color: #FF8A00;">1小时</text></view>
			</view>
			<view style="margin-top: 20rpx;padding-left: 40rpx;margin-bottom: 10rpx;display: flex;align-items: flex-start;">
				<text style="width: 150rpx;">主治擅长：</text>
				<view style="padding-right: 40rpx;width: calc( 100% - 150rpx);">{{docListInfo.disease}}</view>
			</view>
		</view>
		<view style="width: 100%;position: relative;background-color: #FFFFFF;margin-top: 20rpx;padding-top: 20rpx;padding-bottom: 20rpx;">
			<view style="color: #424C4C;padding-left: 40rpx;font-size: 38rpx;font-weight: bolder;position: relative;">
				医生排班
				<view style="width: 70rpx;height: 10rpx;background-color: #BE965B;position: absolute;bottom: -10rpx;left: 120rpx;"></view>
			</view>
			<view style="padding-left: 40rpx;margin-top: 30rpx;" v-if="weekHead&&weekHead.length>0">
				<view class="week-head">
					<view v-for="(item,idx) in weekHead" :key="idx" class="week-cell"
						:style="{
							borderRightWidth: (idx == weekHead.length - 1?'0rpx':'2rpx')
						}">
						{{item}}
					</view>
				</view>
				<view class="week-head">
					<view v-for="(item,idx) in dayHead1" :key="idx" class="week-cell"
						:style="{
							borderRightWidth: (idx == weekHead.length - 1?'0rpx':'2rpx')
						}">
						{{item}}
					</view>
				</view>
				<view class="week-body">
					<view v-for="(item,idx) in dayVal1" :key="idx" class="week-body-cell"
						:style="{
							borderRightWidth: (idx == weekHead.length - 1?'0rpx':'2rpx')
						}">
						<view v-if="item.isScheduling" style="width: 30rpx;height: 30rpx;border-radius: 50%;background-color: #BE965B;">
							
						</view>
					</view>
				</view>
				<view class="week-head">
					<view v-for="(item,idx) in dayHead2" :key="idx" class="week-cell"
						:style="{
							borderRightWidth: (idx == weekHead.length - 1?'0rpx':'2rpx')
						}">
						{{item}}
					</view>
				</view>
				<view class="week-body">
					<view v-for="(item,idx) in dayVal2" :key="idx" class="week-body-cell"
						:style="{
							borderRightWidth: (idx == weekHead.length - 1?'0rpx':'2rpx')
						}">
						<view v-if="item.isScheduling" style="width: 30rpx;height: 30rpx;border-radius: 50%;background-color: #BE965B;">
							
						</view>
					</view>
				</view>
			</view>
			<view style="padding-left: 40rpx;margin-top: 30rpx;" v-else>暂无排班</view>
			<view style="color: #424C4C;padding-left: 40rpx;margin-top: 20rpx;">
				<view style="width: calc( 100% - 40rpx );color: #849494;font-size: 28rpx;">
					说明：以上时间为互联网医院固定排班，接诊时间为早上8点至晚 上5点。其他时间，医师可以利用零碎时间自主接诊，医师在线即可发起在线问诊
				</view>
			</view>
		</view>
		<view style="width: 100%;position: relative;margin-top: 20rpx;background-color: #FFFFFF;padding-top: 20rpx;">
			<view style="color: #424C4C;padding-left: 40rpx;font-size: 38rpx;font-weight: bolder;position: relative;">
				问诊服务
				<view style="width: 70rpx;height: 10rpx;background-color: #BE965B;position: absolute;bottom: -10rpx;left: 120rpx;"></view>
			</view>
			<view style="padding-left: 40rpx;padding-top: 20rpx;">
				<template v-if="deptId==4991">
					<view class="wenz-card"  @click="toWenz(1)">
						<view style="display: flex;align-items: center;padding-left: 20rpx;height: 150rpx;">
							<view style="width: 80rpx;height: 80rpx;display: flex;align-items: center;justify-content: center;background: #EDF6F5;border-radius: 8rpx;">
								<image style="width: 50%;"
									mode="widthFix" src="../static/imgs/zhongyi.png">
								</image>
							</view>
							<view style="margin-left: 10rpx;">
								<view style="font-size: 30rpx;font-weight: bolder;margin-bottom: 5rpx;">用药咨询</view>
								<view style="font-size: 24rpx;color: #424C4C;">与医生进行用药咨询</view>
							</view>
						</view>
						<view style="width: calc(100% - 40rpx );background-color: #E6EAEA;height: 2rpx;margin-left: 20rpx;"></view>
						<view style="display: flex;align-items: center;justify-content: space-between;height:90rpx;">
							<view style="color: #FEA14F;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">免费</view>
							<view style="width: 150rpx;height: 50rpx;background: #BE965B;border-radius: 25rpx;color: #FFFFFF;text-align: center;line-height: 50rpx;margin-right: 20rpx;">
								去咨询
							</view>
						</view>
					</view>
				</template>
				<template v-if="deptId!=4991">
					<view class="wenz-card"  @click="toWenz(1)">
						<view style="display: flex;align-items: center;padding-left: 20rpx;height: 150rpx;">
							<view style="width: 80rpx;height: 80rpx;display: flex;align-items: center;justify-content: center;background: #EDF6F5;border-radius: 8rpx;">
								<image style="width: 50%;"
									mode="widthFix" src="../../static/images/zxwzdoc.png">
								</image>
							</view>
							<view style="margin-left: 10rpx;">
								<view style="font-size: 30rpx;font-weight: bolder;margin-bottom: 5rpx;">在线问诊</view>
								<view style="font-size: 24rpx;color: #424C4C;">通过文字、图片、语音等方式进行实时问诊交流</view>
							</view>
						</view>
						<view style="width: calc(100% - 40rpx );background-color: #E6EAEA;height: 2rpx;margin-left: 20rpx;"></view>
						<view style="display: flex;align-items: center;justify-content: space-between;height:90rpx;">
							<template v-if="docListInfo.ismessage==1">
								<view style="color: #FEA14F;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">￥{{docListInfo.messagefee}}</view>
								<view style="width: 150rpx;height: 50rpx;background: #BE965B;border-radius: 25rpx;color: #FFFFFF;text-align: center;line-height: 50rpx;margin-right: 20rpx;">
									去问诊
								</view>
							</template>
							<template v-else>
								<view style="color: #FEA14F;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">未开通</view>
							</template>
						</view>
					</view>
					<view class="wenz-card" @click="toWenz(2)">
						<view style="display: flex;align-items: center;padding-left: 20rpx;height: 150rpx;">
							<view style="width: 80rpx;height: 80rpx;display: flex;align-items: center;justify-content: center;background: #EDF6F5;border-radius: 8rpx;">
								<image style="width: 50%;"
									mode="widthFix" src="../../static/images/yywzdoc.png">
								</image>
							</view>
							<view style="margin-left: 10rpx;">
								<view style="font-size: 30rpx;font-weight: bolder;margin-bottom: 5rpx;">预约问诊</view>
								<view style="font-size: 24rpx;color: #424C4C;">根据医生排班情况，提前预约问诊，医生可提前回复</view>
							</view>
						</view>
						<view style="width: calc(100% - 40rpx );background-color: #E6EAEA;height: 2rpx;margin-left: 20rpx;"></view>
						<view style="display: flex;align-items: center;justify-content: space-between;height:90rpx;">
							<template v-if="docListInfo.isvideo==1">
								<view style="color: #FEA14F;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">￥{{docListInfo.videofee}}</view>
								<view style="width: 150rpx;height: 50rpx;background: #BE965B;border-radius: 25rpx;color: #FFFFFF;text-align: center;line-height: 50rpx;margin-right: 20rpx;">
									去问诊
								</view>
							</template>
							<template v-else>
								<view style="color: #FEA14F;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">未开通</view>
							</template>
						</view>
					</view>
				
					<view class="wenz-card" @click="toWenz(4)" v-if="isUnscramble==1">
						<view style="display: flex;align-items: center;padding-left: 20rpx;height: 150rpx;">
							<view style="width: 80rpx;height: 80rpx;display: flex;align-items: center;justify-content: center;background: #EDF6F5;border-radius: 8rpx;">
								<image style="width: 50%;"
									mode="widthFix" src="../../static/images/bgjd.png">
								</image>
							</view>
							<view style="margin-left: 10rpx;">
								<view style="font-size: 30rpx;font-weight: bolder;margin-bottom: 5rpx;">报告解读</view>
								<view style="font-size: 24rpx;color: #424C4C;">上传报告，医生在线解读</view>
							</view>
						</view>
						<view style="width: calc(100% - 40rpx );background-color: #E6EAEA;height: 2rpx;margin-left: 20rpx;"></view>
						<view style="display: flex;align-items: center;justify-content: space-between;height:90rpx;">
							<view style="color: #FEA14F;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">¥{{unscrambleFee}}</view>
							<view style="width: 150rpx;height: 50rpx;background: #BE965B;border-radius: 25rpx;color: #FFFFFF;text-align: center;line-height: 50rpx;margin-right: 20rpx;">
								去上传
							</view>
						</view>
					</view>
				</template>
				
				<!-- <view class="wenz-card" @click="toWenz(3)" v-if="docListInfo.isChinDoctor == 1">
					<view style="display: flex;align-items: center;padding-left: 20rpx;height: 150rpx;">
						<view style="width: 80rpx;height: 80rpx;display: flex;align-items: center;justify-content: center;background: #EDF6F5;border-radius: 8rpx;">
							<image style="width: 50%;"
								mode="widthFix" src="../../static/images/zhongyi.png">
							</image>
						</view>
						<view style="margin-left: 10rpx;">
							<view style="font-size: 30rpx;font-weight: bolder;margin-bottom: 5rpx;">中医问诊</view>
							<view style="font-size: 24rpx;color: #424C4C;">与医生进行图文问诊，医生开具中医处方</view>
						</view>
					</view>
					<view style="width: calc(100% - 40rpx );background-color: #E6EAEA;height: 2rpx;margin-left: 20rpx;"></view>
					<view style="display: flex;align-items: center;justify-content: space-between;height:90rpx;">
						<template v-if="docListInfo.isChinDoctor==1">
							<view style="color: #FEA14F;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">￥{{docListInfo.chinDoctorfee}}</view>
							<view style="width: 150rpx;height: 50rpx;border: 2rpx solid #84DDD7;border-radius: 25rpx;color: #84DDD7;text-align: center;line-height: 50rpx;margin-right: 20rpx;">
								去问诊
							</view>
						</template>
						<template v-else>
							<view style="color: #bebebe;font-size: 32rpx;margin-left: 20rpx;font-weight: bold;">未开通</view>
						</template>
					</view>
				</view> -->
				
			</view>
		</view>
		<view style="width: 100%;position: relative;margin-top: 20rpx;background-color: #FFFFFF;padding-top: 20rpx;">
			<view style="color: #424C4C;padding-left: 40rpx;font-size: 38rpx;font-weight: bolder;position: relative;">
				患者评价（{{evaluateTotal}}）
				<view style="width: 70rpx;height: 10rpx;background-color: #BE965B;position: absolute;bottom: -10rpx;left: 120rpx;"></view>
			</view>
			<view style="padding-left: 40rpx;">
				<view class="pj-card" style="padding-left: 40rpx;padding-top: 20rpx;">
					<view class="pj-row" v-for="(evaluateItem,evaluateIdx) in evaluateList" :key="evaluateIdx">
						<view style="color: #424C4C;;">
							<view style="display: flex;align-items: center;">
								<text style="margin-right: 10rpx;">{{evaluateItem.nickname}}</text>
								<image style="width: 26rpx;margin-left: 10rpx;"
									mode="widthFix" src="../../static/images/wjx@2x.png"
									 v-for=" wjxItem in evaluateItem.result">
								</image>
							</view>
							<view style="margin-top: 28rpx;">{{evaluateItem.content}}</view>
						</view>
						<view style="color: #d9d9d9;font-size: 25rpx;">
							{{formatDate2(evaluateItem.gmtCreateDate)}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<view style="width: 100%;position: relative;margin-top: 20rpx;" v-if="isEvaluateMore">
			<view style="width: 100%;text-align: center;color: #2A82E4;padding-bottom: 10rpx;" @click="loadMoreEvaluate">
				加载更多
			</view>
		</view>
		<view style="margin-top: 20rpx;height: 1rpx;" v-else></view>
		<view class="win flex" v-if="isShowTip" @touchmove.stop="defaultEvent">
			<view style="margin: auto;background-color: #FFFFFF;border-radius: 20rpx;width: 80%;height: 70vh;display: flex;flex-direction: column;padding: 20rpx;padding-bottom: 0rpx;align-items: center;">
				<scroll-view scroll-y style="height: calc(100% - 80rpx );overflow-y: auto;padding-top: 20rpx;">
					<view style="text-align: center;margin-bottom: 20rpx;font-size: 34rpx;font-weight: bolder;">问诊须知</view>
					<view style="display: flex;flex-direction: column;align-items: center;width: 100%;">
						<view style="margin-top: 40rpx;width: calc( 100% - 80rpx);">
							1、此次在线服务，将全程通过互联网与医师进 行在线沟通，不是指到线下门诊与医师当面沟 通，请知晓。若需线下面诊，请挂医师线下号
						</view>
						<view style="margin-top: 20rpx;width: calc( 100% - 80rpx);">
							2、目前暂不支持医保结算，均为自费。
						</view>
						<view style="margin-top: 20rpx;width: calc( 100% - 80rpx);">
							3、每次问诊/咨询最多追问10个问题，若医生回复、有效期改为72小时。若医生未在72小时内回复，系统将自动关闭本次问诊/咨询，并为您退款。若问诊次数用完或有效期结束但仍需问诊，请重新提交问诊申请。
						</view>
						<view style="margin-top: 20rpx;width: calc( 100% - 80rpx);">
							4、医生接诊回复需要一定时间，同时鉴于互联网诊疗的局限性，若您病情严重或急需救治，请立即线下就诊。
						</view>
						<view style="margin-top: 20rpx;width: calc( 100% - 80rpx);">
							5、暂时不能提供发票，需要发票的患者请选择线下就诊。
						</view>
						<!-- // <view style="margin-top: 20rpx;width: calc( 100% - 80rpx);">
						// 	6、每日线上开诊时间为早8:00点至晚20:00点。
						// </view> -->
					</view>
					
				</scroll-view>
				<view style="width: 100%;display: flex;align-items: center;">
					<view style="width: 50%;height: 80rpx;line-height: 80rpx;text-align: center;box-sizing: border-box;border-right: 2rpx solid #E8E8E8;" @click="isShowTip=false">取消</view>
					<view style="width: 50%;height: 80rpx;line-height: 80rpx;text-align: center;color: #2A82E4;" @click="queWen()">确认</view>
				</view>
			</view>
		</view>
		<view class="win flex" v-if="getUserWin" @touchmove.stop="">
			<view style="margin: auto;background-color: #FFFFFF;border-radius: 20rpx;width: 90%;height: 400rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;">
				<view style="font-size: 38rpx;text-align: center;font-weight: bolder;">温馨提示</view>
				<view style="font-size: 34rpx;text-align: center;">您尚未登录，请先登录...</view>
				<button class='login_btn' style="background-color: #BE965B;border-radius: 50rpx;width: 300rpx;height: 100rpx;line-height: 100rpx;" 
					type='primary' open-type="getPhoneNumber"  @getphonenumber="getPhoneNumber">
					立即登录
				</button>
			</view>
		</view>
		<view class="win flex" v-if="getUserHead" @touchmove.stop="">
			<view style="margin: auto;background-color: #FFFFFF;border-radius: 20rpx;width: 80%;height: 400rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;">
				<view style="font-size: 36rpx;text-align: center;font-weight: bold;">获取昵称</view>
				<view style="font-size: 30rpx;text-align: center;">是否同意获取微信昵称？</view>
				<view style="display: flex;flex-direction: row;align-items: center;justify-content: space-around;align-items: center;width: 100%;">
					<button type='primary' style="background-color: #F3F3F3;width: 40%;color: #000000;height: 90rpx;line-height: 90rpx;font-size: 30rpx;" @click="getUserHead=false">
						取消
					</button>
					<button type='primary' style="background-color: #BE965B;width: 40%;height: 90rpx;line-height: 90rpx;font-size: 30rpx;" @click="wxGetUserInfo">
						确定
					</button>
				</view>
			</view>
		</view>
		<view class="win flex" v-if="getSubscribe" @touchmove.stop="">
			<view style="margin: auto;background-color: #FFFFFF;border-radius: 20rpx;width: 80%;height: 400rpx;display: flex;flex-direction: column;align-items: center;justify-content: space-around;">
				<view style="font-size: 36rpx;text-align: center;font-weight: bold;">订阅消息</view>
				<view style="font-size: 30rpx;text-align: center;">确认订阅消息？</view>
				<view style="display: flex;flex-direction: row;align-items: center;justify-content: space-around;align-items: center;width: 100%;">
					<button type='primary' style="background-color: #BE965B;width: 40%;height: 90rpx;line-height: 90rpx;font-size: 30rpx;" @click="getrequestSubscribeMessage">
						确定
					</button>
				</view>
			</view>
		</view>
		<uni-popup ref="popup" type="message">
		    <uni-popup-message :type="warnType" :message="warnMessage" :duration="warnTime"></uni-popup-message>
		</uni-popup>
		
		<view style="position: fixed;bottom: 15%;right: 20rpx;
			width: 120rpx;height: 120rpx;background: #BE965B;
			box-shadow: 0px 0px 22rpx 2rpx #BE965B;border-radius: 50%;
			display: flex;flex-direction: column;align-items: center;justify-content: center;z-index: 999;"
			@click="tohome">
			<image src="../../static/images/sy@2x.png" style="width: 50%;" mode="widthFix"></image>
			<view style="color: #FFFFFF;">首页</view>
		</view>
	</view>
</template>

<script>
	const WxAuth =  require('@/utils/wxlogin');
	export default {
		data() {
			return {
				warnMessage:'错误',//消息内容
				warnType:'warn',//消息类型  success/warn/info/error
				warnTime:1000,//消息提醒延长时间
				isLogin: false,
				getUserWin: false,
				getUserHead: false,
				getSubscribe: false,
				isShowTip: false,
				current: 1,
				weekHead:['周一','周二','周三','周四','周五','周六','周日'],
				dayHead1:['06.13','06.14','06.15','06.16','06.17','06.18','06.19'],
				dayHead2:['06.13','06.14','06.15','06.16','06.17','06.18','06.19'],
				dayVal1:[],
				dayVal2:[],
				status:false,
				usrUserId:'',
				wx: "https://app.mzmzb.com",//https://app.mzmzb.com   http://localhost:6110
				winState: false,
				animation: null,
				animationData: null,
				windowWidth: 0,
				docId:null,
				id:null,
				docListInfo:"",
				medDocInfoId:null,
				videofee:null,
				monday:null,
				tuesday:null,
				wednesday:null,
				thursday:null,
				friday:null,
				saturday:null,
				sunday:null,
				timeDay:null,
				docImgs:null,
				recNum:0,
				docStatus:null,
				evaluateList: [],
				evaluateTotal: 0,
				isEvaluateMore:false,
				wenType: undefined,
				doctorTime: [],
				deptId:0,
				isUnscramble:0,
				unscrambleFee:0,
				orderlist:[]
			};
		},
		onLoad(option) {
			this.docId=option.docId;
			this.usrUserId=option.usrUserId;
			this.recNum=option.recNum;
			this.deptId=option.deptId
			this.isUnscramble=option.isUnscramble
			this.unscrambleFee=option.unscrambleFee
			this.getDocInfo();
			this.getDoctorEvaluate();
			this.getDoctorSettingTime();
			this.orderlist=uni.getStorageSync('orderlist')?uni.getStorageSync('orderlist'):[]
			
		},
		onShareAppMessage(){
			return {
				title: this.docListInfo.name,
				path:'/pages4/doctor/index?docId=' + this.docId + '&usrUserId=' + this.usrUserId + '&recNum=' + this.recNum
			}
		},
		methods: {
			getrequestSubscribeMessage(){
				this.getSubscribe = false
				uni.requestSubscribeMessage({
				        tmplIds: ['1JlcLdsSeS3bTUhfYkUjzB0Ts1XWbn3A7C7BHqWSxEg','ZsHYJ0dSyZE-AvmQ8ohFB18PpP-ak8bw46zhEFvDwLk'],
				        success: (res)=> {
							console.log('订阅success',res)
				        },
				        fail: (res)=> { 
							console.log('订阅fail',res)
				        }
				})
			},	
			wxGetUserInfo(){ //第一授权获取用户信息===》按钮触发
				let _this = this;
				// 获取用户信息
				uni.getUserProfile({
					desc: 'weixin',
					success:(infoRes) => {
						this.getUserHead = false
						uni.setStorageSync('nickName',infoRes.userInfo.nickName)
						uni.setStorageSync('avatarUrl',infoRes.userInfo.avatarUrl)
						this.avatarUrl = infoRes.userInfo.avatarUrl
						this.nickName = infoRes.userInfo.nickName
					}
				});
			},
			fxmp(){
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 1,
					summary: this.docListInfo.name,
					success: function (res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function (err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
			tohome(){
				uni.reLaunch({
					url: '/pages/index/index'
				})
			},
			toWenz(val){
				let userId = uni.getStorageSync("usrUserId");
				if(userId){
					this.wenType = val
					this.isShowTip = true
				}else{
					setTimeout(() => {
						this.getUserWin = true
					}, 500)
				}
			},
			queWen(){
				this.isShowTip = false
				if(this.wenType == 1){
					if(this.deptId==4991){
						this.toAdvisorymesseg(this.docListInfo.id,0,'yongyao')
					}else{
						this.toAdvisorymesseg(this.docListInfo.id,this.docListInfo.messagefee)
					}
				}
				if(this.wenType == 2){
					this.toAdvisoryvideo(this.docListInfo.id,this.docListInfo.videofee)
				}
				if(this.wenType == 3){
					this.toAdvisryzhongyi(this.docListInfo.id,this.docListInfo.chinDoctorfee)
				}
				if(this.wenType == 4){
					this.toAdvisorymesseg(this.docListInfo.id,this.unscrambleFee,'baogao')
				}
			},
			//跳转医生详情页
			getDocInfoPage() {
				uni.navigateTo({
					url: '/pages4/doctorDetail/index?docId=' + this.docId + '&usrUserId=' + this.usrUserId
				});
			},
			getPhoneNumber(e){
				var that = this;
				if(e.detail.errMsg =="getPhoneNumber:ok"){
					that.getCode(e.detail.encryptedData,e.detail.iv,this.hspId);
				}
			},
	
		getCode(encryptedData,iv,hspId){
			var that = this;
			 WxAuth.checkSession().then(code => {
				 console.log('getCode=============1',code)
				 WxAuth.getUserIdByPhone(code,encryptedData,iv,hspId).then(res =>{
					 console.log('getCode=============2',res)
						if(res.success){
							that.warnMessage = '登录成功';
							that.warnType = 'success';
							that.$refs.popup.open();
							// that.loginHX(res.result);//登录环信
							let hx=res.result
							that.getUserWin = false
							that.isLogin = true
							that.usrUserId = res.result;
							uni.request({
								url:'https://app.mzmzb.com/application-usrapp/login/wxGetToken.tz?usrUserId='+that.usrUserId,
								method:'POST',
								success:(res)=> {
									uni.setStorageSync('lgToken',res.data.result)
								}
							})
							this.getUserHead = true
							uni.login({
								provider: 'weixin',
								success: (loginres) =>{
									if (loginres.errMsg == "login:ok") {
										that.getOpenIdByHspId(loginres.code)
										// that.getSubscribe = true
										wx.getSetting({
										   withSubscriptions: true,
											success(res) {
												 var itemSettings = res.subscriptionsSetting.itemSettings
												 if (itemSettings) {
												   if (itemSettings['1JlcLdsSeS3bTUhfYkUjzB0Ts1XWbn3A7C7BHqWSxEg'] === 'accept'
														&& itemSettings['ZsHYJ0dSyZE-AvmQ8ohFB18PpP-ak8bw46zhEFvDwLk'] === 'accept') {
														that.getSubscribe = false
												   }else{
														that.getSubscribe = true
												   }
												 }else{
													 that.getSubscribe = true
												 }
											},
											fail(res) {
												that.getSubscribe = true
											}
										 })
									}
								}
							});
		
						}else{
							that.warnMessage = res.errMsg;
							that.warnTime = 2000;
							that.$refs.popup.open();
						}
						
					})
			 });
		},
			getOpenIdByHspId(code){
				uni.request({
					url: this.wx + '/application-usrapp/wx/getOpenIdByHspId.tz',
					method: 'get',
					data: {
						code: code,
						userId: this.usrUserId,
						hspId: this.hspId
					},
					success:(res) =>{
						uni.setStorageSync('openId',res.data.errMsg)
						this.loginHX(this.usrUserId)
					}
				})
			},
			gethx(userId){
					if(uni.getStorageSync('openId')){
						this.passopenid=uni.getStorageSync('openId')
					}
					setTimeout(()=>{
						this.func.$request('login/hxLogin.tz?usrUserId=' + userId,{},'POST').then(item=>{
							var test_account = userId + '';
							uni.setStorageSync("test_psword", item.data.errMsg)
							this.$conn.open({
								apiUrl: this.$im.config.apiURL,
								user: test_account,
								pwd: item.data.errMsg,
								grant_type: "password",
								appKey: this.$im.config.appkey
							});
						})
					},2000)	
				},
			//登录环信
			loginHX(userId){
				var test_account = userId+'';
				let test_psword=''
				if(uni.getStorageSync("test_psword")){
					test_psword = uni.getStorageSync("test_psword")
					uni.setStorageSync("usrUserId",test_account)
					uni.setStorageSync("myUsername",test_account);
					this.$conn.open({
						apiUrl: this.$im.config.apiURL,
						user: test_account,
						pwd: test_psword,
						grant_type: "password",
						appKey: this.$im.config.appkey
					});
				}else{
					test_psword = uni.getStorageSync("test_psword")
					uni.setStorageSync("usrUserId",test_account)
					uni.setStorageSync("myUsername",test_account);
					this.gethx(userId)
					
				}	
			},
			//获取医生详情
			getDocInfo(){
				var that=this;
				// if(that.usrUserId=='null'){
				// 	that.usrUserId='';
				// }
				let data={
					id: this.docId,
					usrUserId:this.usrUserId
				}
				that.func.$request('medDocInfo/getDoctorInfoForUser.tz',data,'GET').then(res=>{
					if (res.data.code = '00000') {
						that.docStatus=res.data.result.status;
						console.log(res.data)
						that.docListInfo=res.data.result;
						if(res.data.result.isvideo==1){
							that.collectDocStatus=res.data.result.isUsrCollectDoc;
							that.monday=res.data.result.medDocSettingTimeIdVideo.monday;
							that.tuesday=res.data.result.medDocSettingTimeIdVideo.tuesday;
							that.wednesday=res.data.result.medDocSettingTimeIdVideo.wednesday;
							that.thursday=res.data.result.medDocSettingTimeIdVideo.thursday;
							that.friday=res.data.result.medDocSettingTimeIdVideo.friday;
							that.saturday=res.data.result.medDocSettingTimeIdVideo.saturday;
							that.sunday=res.data.result.medDocSettingTimeIdVideo.sunday;
							uni.setStorage({
								key:'monday',
								data:res.data.result.medDocSettingTimeIdVideo.monday,
							});
							uni.setStorage({
								key:'tuesday',
								data:res.data.result.medDocSettingTimeIdVideo.tuesday,
							});
							uni.setStorage({
								key:'wednesday',
								data:res.data.result.medDocSettingTimeIdVideo.wednesday,
							});
							uni.setStorage({
								key:'thursday',
								data:res.data.result.medDocSettingTimeIdVideo.thursday,
							});
							uni.setStorage({
								key:'friday',
								data:res.data.result.medDocSettingTimeIdVideo.friday,
							});
							uni.setStorage({
								key:'saturday',
								data:res.data.result.medDocSettingTimeIdVideo.saturday,
							});
							uni.setStorage({
								key:'sunday',
								data:res.data.result.medDocSettingTimeIdVideo.sunday,
							});
							uni.setStorage({
								key:'licensePhoto',
								data:res.data.result.licensePhoto,
							});
						}
					}
				})
				
			},
			getDoctorEvaluate(){
				let data={
					id: this.docId,
					usrUserId:this.usrUserId
				}
				this.func.$request('evaluate/getDoctorEvaluate.tz',data,'GET').then(res=>{
				if (res.data.code = '00000') {
					if(this.evaluateList.length>0){
						let nowList = res.data.result.list
						this.evaluateList.push(...nowList)
					}else{
						this.evaluateList = res.data.result.list
						this.evaluateTotal = res.data.result.total
					}
					this.isEvaluateMore = res.data.result.hasNextPage
				}
				})
				
			},
			loadMoreEvaluate(){
				this.current++
				this.getDoctorEvaluate()
			},
			getDoctorSettingTime(){
				this.weekHead = []
				this.dayHead1 = []
				this.dayHead2 = []
				this.dayVal1 = []
				this.dayVal2 = []
				this.func.$request('wx/getDoctorSettingTime.tz',{docId: this.docId},'GET').then(res=>{
					if (res.data.code = '00000') {
						console.log('getDoctorSettingTime',res.data.result)
						let result = res.data.result
						let doctorTime = []
						if(result.length>7){
							result.forEach((item,idx)=>{
								console.log(idx)
								doctorTime.push({
									isScheduling:item.isScheduling
								})
								if(idx < 7){
									this.weekHead.push(item.week)
									this.dayHead1.push(this.formatDate(item.date))
									this.dayVal1.push({
										isScheduling:item.isScheduling
									})
								}else{
									this.dayHead2.push(this.formatDate(item.date))
									this.dayVal2.push({
										isScheduling:item.isScheduling
									})
								}
							})
						}
						this.doctorTime = doctorTime
						// this.evaluateList = res.data.result.list
					}
				})
			},
			//用户关注该医生
		insertDcoId(id){
			let userId = uni.getStorageSync("usrUserId");
			if(userId){
				var that=this;
				var medDocInfoId=id;
				console.log("医生ID"+medDocInfoId)
				console.log("用户ID"+this.usrUserId)
				if(that.usrUserId=='null'||that.usrUserId==''){
					uni.showLoading({
						title:'请授权登录'
					})
					uni.reLaunch({
						url:'/pages/index/index'
					})
					return 
				}
				let data={
					usrUserId:this.usrUserId,
					medDocInfoId:medDocInfoId
				}
				that.func.$request('userCollect/insertDoctorCollect.tz',data,'POST').then(res=>{
					if (res.data.code = '00000') {
						console.log(res.data)
						that.getDocInfo();
					}
				})
			}else{
				setTimeout(() => {
					this.getUserWin = true
				}, 500)
			}
		},
			//用户取消关注该医生
			deleteDcoId(id){
				var that=this;
				var medDocInfoId=id;
				console.log("医生ID"+medDocInfoId)
				console.log("用户ID"+this.usrUserId)
				let data={
					usrUserId:this.usrUserId,
					medDocInfoId:medDocInfoId
				}
				that.func.$request('userCollect/deleteDoctorCollect.tz',data,'POST').then(res=>{
					if (res.data.code = '00000') {
						console.log(res.data)
						that.getDocInfo();
					}
				})
			},
			//跳转视频咨询首页
			toAdvisoryvideo(id,videofee){
				if(this.usrUserId==''){
					return
				}
				if(this.docListInfo.isvideo != 1){
					uni.showToast({
						title:"医生未开通预约问诊",
						icon: 'error'
					})
					return
				}
				uni.removeStorageSync('keyInfo');
				uni.removeStorageSync('time');
				uni.removeStorageSync('state');
				uni.removeStorageSync('name');
				uni.removeStorageSync('personalFileId');
				uni.removeStorageSync('adressInfo');
				uni.removeStorageSync('medcalRecordId');
				uni.removeStorageSync('isNum');
				uni.removeStorageSync('orderlist');
				var that=this
				var medDocInfoId=id;
				var videofee=videofee;
				uni.setStorageSync('medDocInfoId', medDocInfoId);
				uni.setStorageSync('videofee', videofee);
				uni.setStorageSync('usrUserId', that.usrUserId);
				console.log(medDocInfoId,videofee)
				let orderlist = encodeURIComponent(JSON.stringify(this.orderlist))
				// this.getTime();
				if(that.docStatus==8){
					let timeParm = ''
					if(that.doctorTime && that.doctorTime.length >0 ){
						timeParm = JSON.stringify(that.doctorTime)
					}
					uni.navigateTo({
						url:'/pages5/advisoryvideo/index?usrUserId='+that.usrUserId
						+'&medDocInfoId='+medDocInfoId
						+'&videofee='+videofee
						+'&doctorTime='+timeParm
						+'&videoPeopleNum='+this.docListInfo.videoPeopleNum
						+'&docUserId='+this.docListInfo.usrUserId
						+'&docPhoto='+this.docListInfo.photo+'&docname='+this.docListInfo.name+'&orderlist='+orderlist
					})
				}else{
					uni.showToast({
						title:"医生暂未接诊",
						icon: 'error'
					})
				}
			},
			getTime() {
				var date = new Date();
				var year = date.getFullYear(); //当前年
				var month = date.getMonth() + 1; //当前月
				var day = date.getDate(); //当前日
				var week = date.getDay(); //当前一个周的第几天
				var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				month >= 1 && month <= 9 ? (month = "0" + month) : "";
				day >= 0 && day <= 9 ? (day = "0" + day) : "";
				var timer = year + '-' + month + '-' + day; //当前年月日
				var hours = hour + ':' + minute //当前时分
				this.hoursInfo = timer + ' ' + hours //当前年月日时分
				this.timer = timer
				var weekInfo = week;
				if (weekInfo == 1) {
					this.weeks = '周一';
					this.timeDay=this.monday
				}
				if (weekInfo == 2) {
					this.weeks = '周二';
					this.timeDay=this.tuesday
				}
				if (weekInfo == 3) {
					this.weeks = '周三';
					this.timeDay=this.wednesday
				}
				if (weekInfo == 4) {
					this.weeks = '周四'
					this.timeDay=this.thursday
				}
				if (weekInfo == 5) {
					this.weeks = '周五'
					this.timeDay=this.friday
				}
				if (weekInfo == 6) {
					this.weeks = '周六'
					this.timeDay=this.saturday
				}
				if (weekInfo == 7) {
					this.weeks = '周日'
					this.timeDay=this.sunday
				}
				uni.setStorage({
					key:'timeDay',
					data:this.timeDay,
				});
			},
			//跳转图文咨询首页
			toAdvisorymesseg(id,messagefee,wzlx){
				if(this.usrUserId==''){
					
					return
				}
				
				if(this.docListInfo.ismessage != 1){
					uni.showToast({
						title:"医生未开通在线问诊",
						icon: 'error'
					})
					return
				}
				
				uni.removeStorageSync('keyInfo');
				uni.removeStorageSync('time');
				uni.removeStorageSync('state');
				uni.removeStorageSync('imgs');
				uni.removeStorageSync('name');
				uni.removeStorageSync('personalFileId');
				uni.removeStorageSync('adressInfo');
				uni.removeStorageSync('medcalRecordId');
				uni.removeStorageSync('isNum');
				uni.removeStorageSync('orderlist');
				var that=this
				var medDocInfoId=id;
				var messagefee=messagefee;
				console.log(medDocInfoId,messagefee)
				uni.setStorageSync('medDocInfoId', medDocInfoId);
				uni.setStorageSync('messagefee', messagefee);
				uni.setStorageSync('usrUserId', that.usrUserId);
				let orderlist = encodeURIComponent(JSON.stringify(this.orderlist))
				let data = encodeURIComponent(JSON.stringify(this.orderlist))
				if(that.docStatus==8){
					uni.navigateTo({
						url:'/pages5/advisrymesseg/index?from=doctor'
							+'&docUserId='+this.docListInfo.usrUserId
							+'&medDocInfoId='+medDocInfoId
							+'&docPhoto='+this.docListInfo.photo
							+'&docname='+this.docListInfo.name
							+'&wzlx='+(wzlx?wzlx:'')+'&orderlist='+orderlist
					})
				}else{
					uni.showToast({
						title:"医生暂未接诊",
						icon: 'error'
					})
				}
			},
			toAdvisryzhongyi(id,messagefee){
				if(this.usrUserId==''){
					
					return
				}
				
				if(this.docListInfo.isChinDoctor != 1){
					uni.showToast({
						title:"医生未开通中医问诊",
						icon: 'error'
					})
					return
				}
				
				uni.removeStorageSync('keyInfo');
				uni.removeStorageSync('time');
				uni.removeStorageSync('state');
				uni.removeStorageSync('imgs');
				uni.removeStorageSync('name');
				uni.removeStorageSync('personalFileId');
				uni.removeStorageSync('adressInfo');
				uni.removeStorageSync('medcalRecordId');
				uni.removeStorageSync('isNum');
				var that=this
				var medDocInfoId=id;
				var messagefee=messagefee;
				console.log(medDocInfoId,messagefee)
				uni.setStorageSync('medDocInfoId', medDocInfoId);
				uni.setStorageSync('messagefee', messagefee);
				uni.setStorageSync('usrUserId', that.usrUserId);
				if(that.docStatus==8){
					uni.navigateTo({
						url:'/pages5/advisryzhongyi/index?from=doctor'+'&docUserId='+this.docListInfo.usrUserId+'&medDocInfoId='+medDocInfoId+'&docPhoto='+this.docListInfo.photo+'&docname='+this.docListInfo.name
					})
				}else{
					uni.showToast({
						title:"医生暂未接诊",
						icon: 'error'
					})
				}
			},
			getDocImgs()
			{
				this.status = !this.status;
				this.docImgs=uni.getStorageSync("licensePhoto")
			},
			formatDate(value) {
			  var date = new Date(value);
			  var m = date.getMonth() + 1,
			    d = date.getDate();
			  if (m < 10) { m = '0' + m; }
			  if (d < 10) { d = '0' + d; }
			  return m + '.' + d
			},
			formatDate2(value) {
			  var date = new Date(value);
			  var y =  date.getFullYear(),
				m = date.getMonth() + 1,
			    d = date.getDate();
			  if (m < 10) { m = '0' + m; }
			  if (d < 10) { d = '0' + d; }
			  return y+'-'+m + '-' + d
			}
		}
	};
</script>

<style lang="less">
	.fx-btn::after{
		border-width: 0rpx;
	}
	.win {
		position: fixed;
		width: 100%;
		height: 100vh;
		left: 0;
		top: 0;
		z-index: 20;
		background: rgba(0, 0, 0, 0.3);
	}
	.week-head,.week-body{
		display: flex;
		justify-content: space-around;
		width: calc( 100% - 40rpx);
		border: 2rpx solid #D3D3D3;
		box-sizing: border-box;
		.week-cell,.week-body-cell{
			width: 14.2%;
			text-align: center;
			font-size: 24rpx;
			border-right-style: solid;
			border-right-color: #D3D3D3;
			box-sizing: border-box;
		}
	}
	.week-head{
		background-color: #E4E4E4;
		.week-cell{
			padding-top: 10rpx;
			padding-bottom: 10rpx;
		}
	}
	.week-body{
		background-color: #FFFFFF;
		.week-body-cell{
			height: 58rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
	.wenz-card{
		width: calc(100% - 40rpx );
		height: 250rpx;
		background: #FFFFFF;
		border: 2rpx solid #F2F9F9;
		box-shadow: 0px 2rpx 20rpx 2rpx rgba(162, 215, 211, 0.16);
		border-radius: 26rpx;
		margin-top: 10rpx;
	}
	.pj-card{
		width: calc(100% - 40rpx );
		min-height: 100rpx;
		background: #FFFFFF;
		border: 2rpx solid #F2F9F9;
		box-shadow: 0px 2rpx 20rpx 2rpx rgba(162, 215, 211, 0.16);
		border-radius: 26rpx;
		margin-top: 30rpx;
		.pj-row{
			width: calc(100% - 40rpx );
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-bottom: 40rpx;
		}
	}
</style>
